#include <iostream>
#include "BinarySearchTree.h"
using namespace std;

int main()
{
	///关于左值引用和右值引用！
	/*int k = 10;
	int &a = k;
	int && b = k*2;
	cout << a << endl << b << endl << k<<"end"<<endl;
	k = 100;
	cout << a << endl << b << endl << k;
	*/

	///测试BinarySearchTree的功能。
	BinarySearchTree<double> tree1;
	//test insert.
	tree1.insert(1.5);
	tree1.insert(2.0);
	tree1.insert(0.5);
	tree1.insert(1.0);
	tree1.insert(0.0);
	//test contains.
	cout << "（逻辑判断：0为否，1为是）" << endl << "is 1.0 in tree1?  " << tree1.contains(1.0) << endl;
	cout << "is 10 in tree1?  " << tree1.contains(10) << endl;
	//test findMin and findMax.
	cout << endl << "输出最大值最小值: " << endl << "the minimum is  " << tree1.findMin() << endl;
	cout << "the maximum is  " << tree1.findMax() << endl << endl << "输出tree1:" << endl;
	tree1.printTree();
	//test remove .
	cout << endl << "测试remove的功能" << endl;
	tree1.remove(2.0);
	cout << "remove 2.0 之后的tree1 ：" << endl;
	tree1.printTree();
	cout << endl << "remove 2.0之后的输出最大值最小值: " << endl << "the minimum is  " << tree1.findMin() << endl;
	cout << "the maximum is  " << tree1.findMax() << endl << endl;



	///测试作业中两个函数的功能。

	///test BST_sort.
	cout << "//////HOMEWORK one" << endl << endl << "对函数BST_sort进行测试： " << endl;
	BinarySearchTree<double> a;
	vector<double> data;
	data.push_back(1.5);
	data.push_back(2.0);
	data.push_back(0.5);
	data.push_back(1.0);
	data.push_back(0.0);
	//输出初始的_data.
	cout << "the test vector is ：   ";
	for (int i = 0; i < data.size(); i++)
	{
		cout << data[i] << "     ";
	}
	cout << endl;
	//
	data = a.BST_sort(data);
	//输出由vector得到的tree。
	cout << "the tree is:  " << endl;
	a.printTree();
	//输出覆盖后的_data.
	cout << "the final vector is:  ";
	for (int i = 0; i < data.size(); i++)
	{
		cout << data[i] << "     ";
	}

	///test Randomized_BST_sort.
	cout << endl << endl << "//////HOMEWORK two" << endl << endl << "对函数Randomized_BST_sort进行测试： " << endl;
	BinarySearchTree<double> b;
	vector<double> data_;
	data_.push_back(1.5);
	data_.push_back(2.0);
	data_.push_back(0.5);
	data_.push_back(1.0);
	data_.push_back(0.0);
	//输出初始的_data.

	cout << "the test vector is ：   ";
	for (int i = 0; i < data_.size(); i++)
	{
		cout << data_[i] << "     ";
	}
	cout << endl;
	//
	data_ = a.Randomized_BST_sort(data);
	//输出由vector得到的tree。
	cout << "the tree is:  " << endl;
	a.printTree();

	//输出覆盖后的_data.
	cout << "the final vector is:  ";
	for (int i = 0; i < data_.size(); i++)
	{
		cout << data_[i] << "     ";
	}
};
